<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="oms" uri="http://www.sf-express.com/tags/fn"%>
<link rel="stylesheet" type="text/css" href="${oms:static()}/dtree/dtree.css">
<script type="text/javascript">
var d = new dTree('d');
	$(function(){
		
		//d.add(100,-1,"系统管理员");//根节点的父节点必须为-1；
		<c:forEach var="role" items="${roles}" varStatus="status">
				d.add(
						<c:out value="${role.id }"></c:out>,
						-1,
						"<c:out value="${role.name }"></c:out>",
						"", "roleList");
		</c:forEach>
		$("#dtree").html(d.toString());
		
		$("#saveButton").click(function(){
			getCheckedNodesId();
			myDialog.close();
			
		});
	});

</script>
			<form  method="post" id="form" action="">
				<ul class="all_list">
						<li class="clearfix">
							<span class="all_title l">角色列表：</span>
							<span class="l">
							<div class="dtreediv" style="height:450px;width:350px;"><div id="dtree" style="margin-left: 8px;"></div></div>
							</span>
						</li>
						<li>
							<span class="all_title"></span>
							<span><input type="button" id="saveButton" class="btn_blue" name="saveButton"
								value="确认"></span>
						</li>
						<c:forEach var="role" items="${mySelectRoleIdList}">
							<input name="myPermissionList" type="hidden"
								value="<c:out value='${role}'></c:out>" />
						</c:forEach>
				</ul>
			</form>
			<script type="text/javascript">
			$(function(){
				$('input[name="myPermissionList"]').each(function(){
					 $('#'+$(this).val()).attr("checked",true);
				});  
			});
			
				function getCheckedNodesId() {
					var str="";
					var s = "";
					$("input[type='checkbox']:checked").each(function() {
						str+= $(this).attr("id")+",";
						s += $(this).parent().find("label").html()+",";
					});
					$('#roleListId', window.parent.document).attr("value",str.slice(0,str.length-1));
					$('#roleList', window.parent.document).attr("value",s.slice(0,s.length-1));
				}
			</script>

